﻿
// -------------------------------------------------------------------------------------------------
//
//    This library is free software; you can redistribute it and/or
//    modify it under the terms of the GNU Lesser General Public
//    License as published by the Free Software Foundation; either
//    version 2.1 of the License, or (at your option) any later version.
//
//    This library is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//    Lesser General Public License for more details.
//
//    You should have received a copy of the GNU Lesser General Public
//    License along with this library; if not, write to the Free Software
//    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//
// -------------------------------------------------------------------------------------------------

using Roslyn.Compilers.CSharp;
using Roslyn.Scripting.CSharp;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QInjection.Injector
{
    internal class QueueSyntax : IEnumerable<SyntaxNode>
    {
        private Queue<SyntaxNode> _codequeue;

        internal QueueSyntax()
        {
            _codequeue = new Queue<SyntaxNode>();
        }

        internal void Enqueue(SyntaxNode node)
        {
            _codequeue.Enqueue(node);
        }

        internal void Enqueue(SyntaxList<SyntaxNode> nodeList)
        {
            foreach (var n in nodeList)
                _codequeue.Enqueue(n);
        }

        internal void Enqueue(SyntaxList<MemberDeclarationSyntax> memberList)
        {
            foreach (var m in memberList)
                _codequeue.Enqueue(m);
        }

        internal void Enqueue(SyntaxList<StatementSyntax> syntaxList)
        {
            foreach (var s in syntaxList)
                _codequeue.Enqueue(s);
        }

        internal SyntaxNode Dequeue()
        {
            if (_codequeue.Count() > 0)
                return _codequeue.Dequeue();
            else
                return null;
        }

        public IEnumerator<SyntaxNode> GetEnumerator()
        {
            return _codequeue.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return _codequeue.GetEnumerator();
        }

    }
}
